Skip to content

Instantly share code, notes, and snippets.

@tylerneylon
tylerneylon / copy.lua
Last active May 18, 2024 16:41
How to deep copy Lua values.
-- copy.lua
--
-- Lua functions of varying complexity to deep copy tables.
--
-- 1. The Problem.
--
-- Here's an example to see why deep copies are useful. Let's
-- say function f receives a table parameter t, and it wants to
@msrose
msrose / combining-git-repositories.md
Last active May 18, 2024 16:40
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

@dhh
dhh / linux-setup.sh
Last active May 18, 2024 16:39
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl btop \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
#!/bin/sh
docker run -t -e UID="$(id -u)" -e GID="$(id -g)" -v "$PWD":/w -w /tmp --rm alpine sh -c 'wget "https://github.com/Tomas-M/iotop/archive/master.zip" && unzip master.zip && cd iotop-master && apk add gcc make ncurses-dev linux-headers ncurses-static musl-dev && V=1 LIBS="-no-pie -static -static-libgcc -static-libstdc++" make && strip -s iotop && chown "$UID:$GID" iotop && chmod +x iotop && mv iotop /w/'
@Ravarcheon
Ravarcheon / spectralRotation.py
Created May 18, 2024 13:23
rotates an audio file by 90 degrees in the spectrum while being a reversible process with minimal loss (only floating point errors which are like -150 dB but thats literally silence ahaha~)
import numpy as np
import soundfile as sf
from scipy.fftpack import fft, ifft
def rotateSignal(signal,flip):
if flip:
signal = signal[::-1]
x = np.concatenate((signal, signal[1:][::-1])) # concatenating the array with a reverse of itself makes it such that the fourier transform doesn't layer over a reversed version of itself in the inverse fft
rotSig = np.real(ifft(x))
#!/usr/bin/env bash
mkfifo /tmp/fifo1 /tmp/fifo2
while read a; do echo "FIFO1: $a"; done < /tmp/fifo1 & exec 7> /tmp/fifo1
exec 8> >(while read a; do echo "FD8: $a, to fd7"; done >&7)
exec 3>&1
(
(
(
@denji
denji / golang-tls.md
Last active May 18, 2024 16:33 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@spyesx
spyesx / readme.md
Last active May 18, 2024 16:32
Clean up old linux kernels

Remove old linux kernels

Script way

# Dry run to check
bash remove-old-kernels.sh

# Run
bash remove-old-kernels.sh exec
@nberlette
nberlette / bmw-e90.dbc
Last active May 18, 2024 16:30
BMW E90 CAN bus definitions
VERSION "BMW_E90_0.0.8"
NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 18, 2024 16:25
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');